#!/usr/bin/python
# -*- coding: UTF-8 -*-

from time import sleep
from MiniBotControlLib import MiniBotControlLib
from BwSensorLib import BwSensorLib

# 声明控制库对象
mlib = MiniBotControlLib("udp")
# 声明传感器库对象
sensorlib = BwSensorLib(mlib)
# 连接机器人
ip = "10.10.100.254"
mlib.Connect(ip, 8899)

# 遥控传感器按下对应按钮，点阵显示对应图案
def main():
   # 点阵显示表情
    # 每个list对应显示为数字0～9
    numberData = [[0x07,0x05,0x05,0x05,0x07],[0x02,0x06,0x02,0x02,0x07],[0x07,0x01,0x07,0x04,0x07],
                [0x07,0x01,0x07,0x01,0x07],[0x05,0x05,0x07,0x01,0x01],[0x07,0x04,0x07,0x01,0x07],
                [0x07,0x04,0x07,0x05,0x07],[0x07,0x01,0x01,0x01,0x01],[0x07,0x05,0x07,0x05,0x07],
                [0x07,0x05,0x07,0x01,0x07]] 
   while 1:
      print("等待遥控传感器输入..")
      remote = sensorlib.readRemoteSensor()
      # 按下按钮"1"
      if(remote==10):
         sensorlib.setMatrixSensor(displayData[1]) # 显示1
      # 按下按钮"2"
      elif(remote==11):
         sensorlib.setMatrixSensor(displayData[2]) # 显示2
      # 按下按钮"3"
      elif(remote==12):
         sensorlib.setMatrixSensor(displayData[3]) # 显示3
      # 按下按钮"4"
      elif(remote==13):
         sensorlib.setMatrixSensor(displayData[4]) # 显示4  
      # 按下按钮"5"
      elif(remote==14):
         sensorlib.setMatrixSensor(displayData[5]) # 显示5
      # 按下按钮"6"
      elif(remote==15):
         sensorlib.setMatrixSensor(displayData[6]) # 显示6

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print(" Program closed! ")
    pass




